package cn.hsw.platform.controller;

import cn.hsw.platform.core.base.BaseController;
import cn.hsw.platform.core.dto.ResultDto;
import cn.hsw.platform.core.util.ResultUtil;
import cn.hsw.platform.util.SnowFlakeUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 主键ID生成
 * @author 李子木
 */
@RestController
public class SnowFlakeIdController extends BaseController {

    /**
     * 获取ID
     * @return ID
     */
    @PostMapping("/generate")
    public ResultDto<Long> generate(){

        long id = SnowFlakeUtil.getInstance().nextId();

        return ResultUtil.success(id);
    }
}
